home *** CD-ROM | disk | FTP | other *** search
/ Champak 62 / Volume 62 - JOGO DISK .iso / Games / room-maker.swf / scripts / frame_1 / DoAction.as
Text File  |  2008-03-17  |  3KB  |  99 lines

  1. function init()
  2. {
  3.    menuText = ["","","","","","","",""];
  4.    iconFrames = [2,3,4,5,6,7,8,9];
  5.    currentLeftItem = 0;
  6.    gridX = 140;
  7.    gridY = 26;
  8.    numColumns = 5;
  9.    hGap = 12;
  10.    numColumns = numColumns <= menuText.length ? numColumns : menuText.length;
  11.    currentLeftItem = currentLeftItem >= 0 ? currentLeftItem : 0;
  12.    currentLeftItem = currentLeftItem <= menuText.length - numColumns ? currentLeftItem : menuText.length - numColumns;
  13.    generateCarouselMenu(menuText,iconFrames,currentLeftItem,gridX,gridY,numColumns,hGap);
  14. }
  15. function generateCarouselMenu(menuText, frameList, leftItemNum, gridX, gridY, numColumns, hGap)
  16. {
  17.    _root.attachMovie("emptyclip","grid",1000);
  18.    grid._x = gridX;
  19.    grid._y = gridY;
  20.    grid.attachMovie("tile","tile" + leftItemNum,2);
  21.    grid["tile" + leftItemNum].text = menuText[leftItemNum];
  22.    grid["tile" + leftItemNum].icon.gotoAndStop(frameList[leftItemNum]);
  23.    var tileWidth = grid["tile" + leftItemNum]._width;
  24.    if(numColumns < menuText.length)
  25.    {
  26.       grid.attachMovie("navArrow","leftArrow",0);
  27.       grid.leftArrow._xscale = -100;
  28.       grid.leftArrow._alpha = 60;
  29.       grid.leftArrow._x -= hGap - 10;
  30.       grid.leftArrow._y = grid["tile" + leftItemNum]._height / 2 - grid.leftArrow._height / 2;
  31.       if(leftItemNum == 0)
  32.       {
  33.          grid.leftArrow.gotoAndStop("disabled");
  34.       }
  35.    }
  36.    var columnXOffset = tileWidth + hGap;
  37.    var i = 1;
  38.    while(i < numColumns)
  39.    {
  40.       grid.attachMovie("tile","tile" + (leftItemNum + i),2 + i);
  41.       var thisTile = grid["tile" + (leftItemNum + i)];
  42.       thisTile.icon.gotoAndStop(frameList[leftItemNum + i]);
  43.       thisTile._x = columnXOffset;
  44.       columnXOffset += tileWidth + hGap;
  45.       i++;
  46.    }
  47.    if(numColumns < menuText.length)
  48.    {
  49.       grid.attachMovie("navArrow","rightArrow",2 + i);
  50.       grid.rightArrow._x = columnXOffset + 30;
  51.       grid.rightArrow._alpha = 60;
  52.       grid.rightArrow._y = grid["tile" + leftItemNum]._height / 2 - grid.rightArrow._height / 2;
  53.       if(leftItemNum == menuText.length - numColumns)
  54.       {
  55.          grid.rightArrow.gotoAndStop("disabled");
  56.       }
  57.    }
  58. }
  59. function next()
  60. {
  61.    if(!_root.mc_hittester.hitTest(_root.help))
  62.    {
  63.       if(currentLeftItem < menuText.length - numColumns)
  64.       {
  65.          currentLeftItem++;
  66.          generateCarouselMenu(menuText,iconFrames,currentLeftItem,gridX,gridY,numColumns,hGap);
  67.       }
  68.    }
  69. }
  70. function prev()
  71. {
  72.    if(!_root.mc_hittester.hitTest(_root.help))
  73.    {
  74.       if(currentLeftItem > 0)
  75.       {
  76.          currentLeftItem--;
  77.          generateCarouselMenu(menuText,iconFrames,currentLeftItem,gridX,gridY,numColumns,hGap);
  78.       }
  79.    }
  80. }
  81. function removeMenu()
  82. {
  83.    removeMovieClip("rightArrow");
  84.    removeMovieClip("lefttArrow");
  85.    removeMovieClip("grid");
  86. }
  87. s1 = new Sound();
  88. s2 = new Sound();
  89. s3 = new Sound();
  90. s4 = new Sound();
  91. s5 = new Sound();
  92. s6 = new Sound();
  93. s1.loadSound("s1.mp3",false);
  94. s2.loadSound("s2.mp3",false);
  95. s3.loadSound("s3.mp3",false);
  96. s4.loadSound("s4.mp3",false);
  97. s5.loadSound("s5.mp3",false);
  98. s6.loadSound("BITE.mp3",false);
  99.